package com.platform.common.utils.file.minio;

import com.platform.common.utils.DateUtils;
import com.platform.common.utils.file.FileUtils;

import java.io.File;

/**
 * @author Huangkai
 */
public class FileKeyUtils {
    public static String getFileKey(File file, Integer type){
        StringBuffer stringBuffer = new StringBuffer();
        //如果传过来的是图片
        switch (type){
            case 0:
                stringBuffer.append("static/picture/");
                stringBuffer.append(DateUtils.getDate() + "/" + FileUtils.getName(file.getName()));
                break;
            case 1:
                stringBuffer.append("static/video/");
                stringBuffer.append(DateUtils.getDate() + "/" + FileUtils.getName(file.getName()));
                break;
            case 2:
                stringBuffer.append("static/txt/");
                stringBuffer.append(DateUtils.getDate() + "/" + FileUtils.getName(file.getName()));
                break;
            default:
                stringBuffer.append("static/file/");
                stringBuffer.append(DateUtils.getDate() + "/" + FileUtils.getName(file.getName()));
                break;
        }
        return stringBuffer.toString();
    }
}
